﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/MasterPage2.master" AutoEventWireup="true" CodeFile="Admin_ThemSanPham.aspx.cs" Inherits="KhachHangDaiChung_KhachHangDaiChung_ThemSanPham" Title="Untitled Page" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>



<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
   <asp:ScriptManager ID="ScriptManager1" runat="server"/>
    <center>
        <h2>THÊM SẢN PHẨM</h2>    </center>
        
            <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
                DeleteMethod="Delete" InsertMethod="Insert" 
                OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                TypeName="DataDSTableAdapters.DONVITINHTableAdapter" UpdateMethod="Update">
                <DeleteParameters>
                    <asp:Parameter Name="Original_Id" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="TenDonVi" Type="String" />
                    <asp:Parameter Name="Original_Id" Type="Int32" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="TenDonVi" Type="String" />
                </InsertParameters>
            </asp:ObjectDataSource>           
            
    <table border="0" cellspacing="10" cellpadding="0" width="740px">
    
        
    	<tr>
    		<td style="width:320px; vertical-align:top">
    		    <asp:TreeView ID="tvPhanLoai" runat="server" 
                    ontreenodepopulate="tvPhanLoai_TreeNodePopulate" ExpandDepth="1">
                    <SelectedNodeStyle BackColor="#D0D0D0" />
                </asp:TreeView>
    		</td>
    		<td style="width:420px; vertical-align:top">
    		<table align="left">
            <tr>
                <td align="right" class="style2">
                    Phân Loại:
                </td>
                <td align="left" class="style3">
                    <asp:TextBox ID="txtLoaiSP" runat="server" ReadOnly="true"></asp:TextBox>
                    <asp:RequiredFieldValidator ControlToValidate="txtLoaiSP" ID="RequiredFieldValidator5" runat="server" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                <a href="Admin_XemDanhSachPhanLoai.aspx">Thêm mới loại sản phẩm</a>
                 </td>
            </tr>
               
            
            <tr>
                <td align="right" class="style2">
                    Mã Sản Phẩm:
                </td>
                <td align="left" class="style3">
                    <asp:TextBox ID="txtMaSanPham" runat="server" Width="230px"></asp:TextBox>
                
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                        ControlToValidate="txtMaSanPham" ErrorMessage="*"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td align="right" class="style2">
                    Tên Sản Phẩm:</td>
                <td align="left" class="style3">
                    <asp:TextBox ID="txtTenSanPham" runat="server" Width="230px"></asp:TextBox>
                
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                        ControlToValidate="txtTenSanPham" 
                        ErrorMessage="*"></asp:RequiredFieldValidator>
                </td>
            </tr>
            
            <tr>
                <td align="right" class="style2">
                    Số Lượng:
                </td>
                <td align="left" class="style3">
                    <asp:TextBox ID="txtSoLuong" runat="server" Width="100px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                        ControlToValidate="txtSoLuong" ErrorMessage="*"></asp:RequiredFieldValidator>
                    <asp:RangeValidator ControlToValidate="txtSoLuong" ID="RangeValidator1" runat="server" ErrorMessage="Giá trị không hợp lệ" MaximumValue="99999" MinimumValue="0"></asp:RangeValidator>           
                        
                </td>
            </tr>
            
            <tr>
                <td align="right" class="style2">
                    Giá:
                </td>
                <td align="left" class="style3">
                    <asp:TextBox ID="txtGiaMoi" runat="server" Width="120px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                        ControlToValidate="txtGiaMoi" ErrorMessage="*"></asp:RequiredFieldValidator>
                    <asp:RangeValidator ControlToValidate="txtGiaMoi" ID="RangeValidator2" runat="server" ErrorMessage="Giá không hợp lệ" MaximumValue="999999999999" MinimumValue="0"></asp:RangeValidator>
                    
                </td>                
            </tr>
            
            <tr>
                <td align="right" class="style2">
                    Đơn Vị Tính:
                </td>
                <td align="left" class="style3">
                    <asp:DropDownList ID="comboboxDonViTinh" runat="server" 
                        DataSourceID="ObjectDataSource2" DataTextField="TenDonVi" DataValueField="Id">
                    </asp:DropDownList>
                    
                    <a href="">Thêm đơn vị tính mới</a>
                    </td>               
            </tr>
                        
            <tr>
                <td align="right" class="style2">
                    Hình Ảnh:
                </td>
                <td align="left" class="style3">
                    <asp:FileUpload ID="fileuploadHinhAnh" runat="server" />
                </td>
                
            </tr>
            
            <tr>
                <td align="right" class="style2">
                    Nhà Sản Xuất:
                </td>
                <td align="left" class="style3">
                    <asp:TextBox ID="txtNhaSanXuat" runat="server" Width="230px"></asp:TextBox>
                </td>                
            </tr>
            
             <tr>
                <td align="right" class="style2">
                    Trạng Thái Bán:
                </td>
                <td align="left" class="style3">
                    <asp:RadioButton ID="rbtTrangThaiBan1" runat="server" Checked="true" Text="Được phép bán" 
                        GroupName="TrangThai"  />
                    <asp:RadioButton ID="rbtTrangThaiBan2" runat="server" Text="Không được bán" 
                        GroupName="TrangThai"  />
                </td>
                
            </tr>
            
            <tr>
                <td align="right" class="style2">
                    Mô Tả:
                </td>
                <td align="left" class="style3">
                    <asp:TextBox ID="txtMoTa" runat="server" Height="67px" TextMode="MultiLine" 
                        Width="270px"></asp:TextBox>
                </td>
                
            </tr>
            <% 
       if (tvPhanLoai.SelectedValue !="")
       {
           string strconnection = ConfigurationManager.ConnectionStrings["SMOConnectionString"].ConnectionString;
           System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(strconnection);
           connection.Open();
           string query = "select tt.* " +
                          "from PHANLOAI_THUOCTINH pltt, THUOCTINH tt " +
                          "where pltt.Id_ThuocTinh=tt.Id and pltt.Id_PhanLoai=" + tvPhanLoai.SelectedValue;
           System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand();
           command.CommandText = query;
           command.Connection = connection;
           System.Data.SqlClient.SqlDataReader dr= command.ExecuteReader();
           if (dr.RecordsAffected != 0)
           {
           
               while (dr.Read())
               {
                   string id = dr["Id"].ToString();
                   string ten = dr["TenThuocTinh"].ToString();
                   Response.Write("<tr>");
                   Response.Write("<td>" + ten + "</td>");
                   Response.Write("<td><input type='text' name='" + id +"'/></td>");
                   Response.Write("</tr>");
               }
               
           }
       }
    %>
            
            
           <tr >
            <td class="itemHeader">Khuyến mãi<asp:CheckBox ID="ckKhuyenMai" runat="server" 
                    oncheckedchanged="ckKhuyenMai_CheckedChanged" AutoPostBack="True" 
                    Checked="True" /></td>
           </tr>       
           <tr>
                <td>
                    <asp:Label ID="lbNgayBatDau" runat="server" Text="Ngày bắt đầu"></asp:Label></td>
                <td>                    
                    <asp:TextBox ID="txtNgayBatDau" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="txtNgayBatDau">*</asp:RequiredFieldValidator>
                    <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtNgayBatDau">
                    </cc1:CalendarExtender>
                    
                    
                </td>
           </tr>
           <tr>
                <td>
                    <asp:Label ID="lbNgayKetThuc" runat="server" Text="Ngày kết thúc"></asp:Label></td>
                <td>                    
                    <asp:TextBox ID="txtNgayKetThuc" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="txtNgayKetThuc">*</asp:RequiredFieldValidator>
                    <cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtNgayKetThuc">
                    </cc1:CalendarExtender>
                    
                    
                </td>
           </tr>         
           <tr>
                <td>
                    <asp:Label ID="lbMoTa" runat="server" Text="Mô tả "></asp:Label></td>
                <td>
                    <asp:TextBox ID="txtMoTaKhuyenMai" runat="server" TextMode="MultiLine"></asp:TextBox></td>
           </tr> 
           <tr>
                <td>
                    <asp:Label ID="lbGiamGia" runat="server" Text="Giảm giá:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtGiamGia" runat="server" Width="50" Text="0"></asp:TextBox> 
                    <asp:Label ID="lbPhanTram" runat="server" Text=" %"></asp:Label></td>
           </tr>
           <tr>
                <td><asp:Label ID="lbSoLuongHinhThuc" runat="server" Text="Số lượng sản phẩm tặng kèm:"></asp:Label> </td>
                <td>                    
                    <asp:Panel ID="Panel1" runat="server">
                    <input type="text" size="4" name="soluonghinhthuc" onkeyup="SoLuongHinhThucChange();"/>
                    </asp:Panel>
                    
                    
                </td>
           </tr>
           
                
           
        </table>
    		</td>
    	</tr>
    </table>
    <div style="padding-left:320px;" id="hinhthucPlaces"></div>
    <div style="padding-left:320px;width:420px; text-align:center"><asp:Button ID="btnThem" runat="server" onclick="btnThem_Click" Text="Thêm" 
                        Width="74px" />
    </div>
    <div id="goOn" style="display:none"></div>
    <div id="goOn2" style="display:none"></div>

            
        
        
        
     
</asp:Content>

